<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tiny FTP: ftp_server.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Tiny FTP
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">ftp_server.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#afe95cbf25cb718882af3b270d8444891">greetings</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="keywordtype">int</span> <a class="code hl_function" href="ftp__server_8c.html#a4297bbb7ddb30e7cc2c896d127501eb5">create_socket</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#a717154ba6392e7882d105c8878e2b89e">bind_to_port</a>(<span class="keyword">struct</span> sockaddr_in client_addr, <span class="keywordtype">int</span> sockfd);</div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#a0cc55115a0b678b249e3bc9044f9d79b">listen_to_port</a>(<span class="keywordtype">int</span> sockfd, <span class="keywordtype">int</span> backlog);</div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="keywordtype">int</span> <a class="code hl_function" href="ftp__server_8c.html#a7ff013fbdf95b96f2d023fec829a0ef5">accept_connections</a>(<span class="keywordtype">int</span> sock_listen);</div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#a80762bccbf172f3bcc3c6149c6c407c5">send_message</a>(<span class="keywordtype">int</span> client_sock, <span class="keywordtype">char</span> *info, <span class="keywordtype">char</span> *extra);</div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="keywordtype">int</span> <a class="code hl_function" href="ftp__server_8c.html#a51e4c16da2d4948788531008dd381d35">recv_message</a>(<span class="keywordtype">int</span> client_sock);</div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="keywordtype">int</span> <a class="code hl_function" href="ftp__server_8c.html#a79275ba100d8e41616e85d2640b4ccdb">validate_username</a>(<span class="keywordtype">char</span> *username);</div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="keywordtype">int</span> <a class="code hl_function" href="ftp__server_8c.html#a05cb29dcebf6f6367e907c50b507177a">validate_password</a>(<span class="keywordtype">char</span> *password, <span class="keywordtype">int</span> mode);</div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#a46870c32ba12c8313bcb7664e55c13ca">user_login</a>(<span class="keywordtype">int</span> client_sock);</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#a3e49a1da2caece9751648f488b1519c3">command_handler</a>(<span class="keywordtype">int</span> client_sock);</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="keywordtype">void</span> <a class="code hl_function" href="ftp__server_8c.html#aaf5d9aef5682b7dbbc48cdc1833b74ea">handle_client_request</a>(<span class="keywordtype">int</span> socket_control);</div>
<div class="ttc" id="aftp__server_8c_html_a05cb29dcebf6f6367e907c50b507177a"><div class="ttname"><a href="ftp__server_8c.html#a05cb29dcebf6f6367e907c50b507177a">validate_password</a></div><div class="ttdeci">int validate_password(char *password, int mode)</div><div class="ttdoc">验证给出的密码是否匹配用户名。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:144</div></div>
<div class="ttc" id="aftp__server_8c_html_a0cc55115a0b678b249e3bc9044f9d79b"><div class="ttname"><a href="ftp__server_8c.html#a0cc55115a0b678b249e3bc9044f9d79b">listen_to_port</a></div><div class="ttdeci">void listen_to_port(int sockfd, int backlog)</div><div class="ttdoc">使套接字监听本地指定端口。若监听失败，将直接退出。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:81</div></div>
<div class="ttc" id="aftp__server_8c_html_a3e49a1da2caece9751648f488b1519c3"><div class="ttname"><a href="ftp__server_8c.html#a3e49a1da2caece9751648f488b1519c3">command_handler</a></div><div class="ttdeci">void command_handler(int socket_control)</div><div class="ttdoc">反复处理用户端发送的指令。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:213</div></div>
<div class="ttc" id="aftp__server_8c_html_a4297bbb7ddb30e7cc2c896d127501eb5"><div class="ttname"><a href="ftp__server_8c.html#a4297bbb7ddb30e7cc2c896d127501eb5">create_socket</a></div><div class="ttdeci">int create_socket(void)</div><div class="ttdoc">创建一个TCP套接字。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:51</div></div>
<div class="ttc" id="aftp__server_8c_html_a46870c32ba12c8313bcb7664e55c13ca"><div class="ttname"><a href="ftp__server_8c.html#a46870c32ba12c8313bcb7664e55c13ca">user_login</a></div><div class="ttdeci">void user_login(int socket_control)</div><div class="ttdoc">处理用户登入的模块。如果用户没有正确选择以匿名或以帐户模式登录，则一直请求用户输入帐号密码，否则不允许后续操作。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:156</div></div>
<div class="ttc" id="aftp__server_8c_html_a51e4c16da2d4948788531008dd381d35"><div class="ttname"><a href="ftp__server_8c.html#a51e4c16da2d4948788531008dd381d35">recv_message</a></div><div class="ttdeci">int recv_message(int socket_control)</div><div class="ttdoc">接收客户端信息。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:120</div></div>
<div class="ttc" id="aftp__server_8c_html_a717154ba6392e7882d105c8878e2b89e"><div class="ttname"><a href="ftp__server_8c.html#a717154ba6392e7882d105c8878e2b89e">bind_to_port</a></div><div class="ttdeci">void bind_to_port(struct sockaddr_in server_addr, int sockfd)</div><div class="ttdoc">绑定到指定端口上。若绑定不成功，将会直接退出程序。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:64</div></div>
<div class="ttc" id="aftp__server_8c_html_a79275ba100d8e41616e85d2640b4ccdb"><div class="ttname"><a href="ftp__server_8c.html#a79275ba100d8e41616e85d2640b4ccdb">validate_username</a></div><div class="ttdeci">int validate_username(char *username)</div><div class="ttdoc">验证给出的用户名是否存在。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:130</div></div>
<div class="ttc" id="aftp__server_8c_html_a7ff013fbdf95b96f2d023fec829a0ef5"><div class="ttname"><a href="ftp__server_8c.html#a7ff013fbdf95b96f2d023fec829a0ef5">accept_connections</a></div><div class="ttdeci">int accept_connections(int sock_listen)</div><div class="ttdoc">在当前监听的本地端口，接受来自外部的连接请求。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:92</div></div>
<div class="ttc" id="aftp__server_8c_html_a80762bccbf172f3bcc3c6149c6c407c5"><div class="ttname"><a href="ftp__server_8c.html#a80762bccbf172f3bcc3c6149c6c407c5">send_message</a></div><div class="ttdeci">void send_message(int socket_control, char *info, char *extra)</div><div class="ttdoc">向客户端发送信息。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:109</div></div>
<div class="ttc" id="aftp__server_8c_html_aaf5d9aef5682b7dbbc48cdc1833b74ea"><div class="ttname"><a href="ftp__server_8c.html#aaf5d9aef5682b7dbbc48cdc1833b74ea">handle_client_request</a></div><div class="ttdeci">void handle_client_request(int socket_control)</div><div class="ttdoc">处理用户的请求，包括登录和命令处理。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:286</div></div>
<div class="ttc" id="aftp__server_8c_html_afe95cbf25cb718882af3b270d8444891"><div class="ttname"><a href="ftp__server_8c.html#afe95cbf25cb718882af3b270d8444891">greetings</a></div><div class="ttdeci">void greetings(void)</div><div class="ttdoc">server的欢迎语。</div><div class="ttdef"><b>Definition:</b> ftp_server.c:45</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
